package com.flyco.modules.oms.handle.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.flyco.common.util.DateUtils;
import com.flyco.common.util.HttpUtil;
import com.flyco.common.util.oConvertUtils;
import com.flyco.modules.oms.handle.IOmsOrderReturnApplyHandle;
import com.flyco.modules.util.ApiUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.util.DigestUtils;

import java.io.UnsupportedEncodingException;
import java.util.*;

@Slf4j
@Component
public class OmsOrderReturnApplyHandleImpl implements IOmsOrderReturnApplyHandle {

    @Override
    public String sendOrderRefundById(String orderId, String applyId) {
        return syncToPay(orderId,applyId);
    }

    @Override
    public void sendOrderRefund() {

    }


    private String syncToPay(String orderId, String applyId) {
        StringBuilder url = new StringBuilder();
        url.append(ApiUtil.getPayUrl());
        url.append("api/payinner/refund/");
        url.append(orderId + "-" + applyId);
        log.info("url:" + url.toString());
        String result = HttpUtil.getRequest(url.toString());
        log.info("result:" + result);
        return result;
    }


}
